Printable Version of Topic

Click here to view this topic in its original format

UtterAccess Forums _ Interface Design _ Switchboard - Add Button

Posted by: whatsit Apr 28 2019, 05:29 PM

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

Posted by: GroverParkGeorge Apr 28 2019, 07:25 PM

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

Posted by: tina t Apr 28 2019, 07:58 PM

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

Posted by: whatsit Apr 29 2019, 09:28 AM

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...

Posted by: tina t Apr 29 2019, 01:59 PM

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

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