UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Switchboard - Add Button, Access 2013    
 
   
whatsit
post Apr 28 2019, 05:29 PM
Post#1



Posts: 128
Joined: 22-September 10
From: Northern California Foothills


Hello
I am attempting to add some new features to an old application in which I used the switchboard for initial user interface. I want to add a button to the switchboard that will open an excel workbook using VBA.
I used the switchboard manager and chose the “run code” option. After researching on the web, I followed instructions and:

Created a module “OpenBudgetFromAccess” and placed the following function in the module

Function OpenBudgetFromAccess()
Dim Apxl As Object
Set Apxl = CreateObject("Excel.Application")

With Apxl
.Application.Visible = True
.workbooks.Open "C:\users\whatsit\desktop\BudgetTemplate.xlsm"
End With
End Function

I get the message “there was an error executing the command” no matter what I try to do – use an .xlsx extension for the workbook, tried declaring it a public function as opposed to just function, etc. I made sure the function name used in the switchboard wizard is correct… What have I missed this time around??

Thanks for any help
Go to the top of the page
 
GroverParkGeorge
post Apr 28 2019, 07:25 PM
Post#2


UA Admin
Posts: 36,043
Joined: 20-June 02
From: Newcastle, WA


Is that folder (under users) designated as a Trusted Location?

--------------------
My Real Name Is George. Grover Park Consulting is where I do business.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 
tina t
post Apr 28 2019, 07:58 PM
Post#3



Posts: 6,152
Joined: 11-November 10
From: SoCal, USA


QUOTE
Created a module “OpenBudgetFromAccess” and placed the following function in the module

Function OpenBudgetFromAccess()
Dim Apxl As Object
Set Apxl = CreateObject("Excel.Application")

With Apxl
.Application.Visible = True
.workbooks.Open "C:\users\whatsit\desktop\BudgetTemplate.xlsm"
End With
End Function

if the module really has the same name as the function, then change the module name, for example

modOpenBudgetFromAccess

and it doesn't seem like you should need to get that fancy just to open a file. suggest you try
CODE
Public Function OpenBudgetFromAccess()

    Application.FollowHyperlink "C:\users\whatsit\desktop\BudgetTemplate.xlsm"

End Function

hth
tina

--------------------
"the wheel never stops turning"
Go to the top of the page
 
whatsit
post Apr 29 2019, 09:28 AM
Post#4



Posts: 128
Joined: 22-September 10
From: Northern California Foothills


Thank you Tina and George for taking the time to respond! Once again, you have solved my problem... The simple act of changing the name of the function to something other than the name of the module fixed the issue. I swear, I don't know how you professionals keep your sanity, or maybe I'm jumping to conclusions???

Honestly, thank you so much...
Go to the top of the page
 
tina t
post Apr 29 2019, 01:59 PM
Post#5



Posts: 6,152
Joined: 11-November 10
From: SoCal, USA


"sanity? we don't need no stinkin' sanity!" ;)

and you're welcome, George and i were glad to help. :) tina

--------------------
"the wheel never stops turning"
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    17th November 2019 - 03:03 AM