Launch code from Macro Problem

I

idtjes3

Hello,

I Want to be able to open an excel file from inside MS Access by using
the switchboard. I created a module from a tutorial i found online that opens
the file perfectly( called Open_Estimate). When I try to create a new button
on my switch board to launch the function and set it to "Run Code", Function
Name: "Open_Estimate", i get an error: ' The object does not contain the
Automation object 'Open_Estimate.'
If i try to launch the code this time through a macro i get a different type
of error. When I go into create>macro i set the new macro to "run code". When
i try to select the function from my databases function list, it wont select
it. Its listed but wont let me click on it ( mm super frustrating to say the
least).
Ive also tried going into the On Click event properties of the
switchboard button, going down to both command 7 and 8 (depending on if i set
the switchboard button to run macro or run code) and tried adding the
argument "Open_Estimate" but that also did not work. What am I doing wrong
here?
 
J

Jeanette Cunningham

Hi,
The second macro errors because if doesn't have the code that opens the
spreadsheet.
If you were doing this using vba code instead of a macro, the same function
that opens excel would also run the code to manipulate the spreadsheet.
I haven't used macros for a long while, but if there is a way to combine all
the steps into a function called from your first macro, you have a better
chance of success.

Jeanette Cunningham
 
I

idtjes3

I figured it out. The problems were many ha ha. For starters, I guess you
cant name the module or the function the same or else it generates errors.
Inside the module code itself, I had "Sub Open_Estimate()" instead of
"Function Open_Estimate()"which is why It couldn't find the Function to
launch on the switchboard. After i fixed those i went into the switchboard
and tried to set the button for Launch code then for the function i typed
Open_Estimate, and now the code runs fine.

Since the code is working from the switchboard, I no longer needed to use a
macro to run it. I went back anyways to try and figure out why it wouldn't
run or why I couldn't select the name from the list. Turned out once I
renamed the function and the module name different from each other, I was
able to select the function from the list of available ones in my DB. Also
when calling a function in a macro you need to add a " ( ) " at the end or it
will not work.

Hope my problems can help people in the future. I cant seem to find a lot
of information on proper function calling and macro running in MS Access.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top