?
Solved

Converting Macro to VBA? Can you convert back?

Posted on 2008-10-11
4
Medium Priority
?
1,292 Views
Last Modified: 2012-05-05
Hello,

I created a macro using the Access GUI, but then I wanted to add some extra code. So I selected the option 'Convert Macros to Visual Basic'. This was great as it allowed me to add some extra code snippets. But in the process it converted my macro into a module.

1) Am I able to convert this module back to a macro?
2) Can I run module's like macros?
0
Comment
Question by:Dozingquinn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 8

Expert Comment

by:Emil_Gray
ID: 22696103
I wouldn't worry about converting a module to a macro. Yes you can. What exactly is the code you are using to call the macro/module?
0
 

Author Comment

by:Dozingquinn
ID: 22696431
Hi Emil,

Below is the code snippet. The reason that I ask whether I can convert the module back to a macro, is because I don't know how to use (or run) modules. I only converted the macro to Visual Basic code so I could add in some more parameters that weren't visible in the Access Macro GUI.

Is there a way to look into the VB code of a macro without converting it into a module?

'------------------------------------------------------------
' mac_excel_patient_export
'
'-
Function mac_excel_patient_export()
On Error GoTo mac_excel_patient_export_Err
 
    DoCmd.TransferSpreadsheet acExport, 10, "qry_excel_patient", "C:\data.xls", True, "Patientsheet"
DoCmd.TransferSpreadsheet acExport, 10, "qry_excel_treatment", "C:\data.xls", True, "Treatmentsheet"
 
mac_excel_patient_export_Exit:
    Exit Function
 
mac_excel_patient_export_Err:
    MsgBox Error$
    Resume mac_excel_patient_export_Exit
 
End Function

Open in new window

0
 
LVL 8

Accepted Solution

by:
Emil_Gray earned 1600 total points
ID: 22696660
What is the code you use to call the macro? Is it a button? At any rate all you need do is substitute the name of the Function where you are calling the Macro. For instance:
Call mac_excel_patient_export
That code will run the function. You may not even need to use the key word "Call" but I'm not sure about that.
0
 

Author Closing Comment

by:Dozingquinn
ID: 31505385
Thanks Emil. I ended up attaching the 'basic' version of the macro to a button - then I viewed the code of the macro and ended up making the alterations there. It was a kind of 'the long way around' but it worked.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question