Solved

Converting Macro to VBA? Can you convert back?

Posted on 2008-10-11
4
1,270 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
  • 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 400 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

839 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