Solved

Converting Macro to VBA? Can you convert back?

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

740 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