How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask Richard Your Own Question

Richard
Richard, Software Specialist
Category: Microsoft Office
Satisfied Customers: 32029
Experience:  Over 15 year experience resolving Microsoft Office Issues
32989067
Type Your Microsoft Office Question Here...
Richard is online now
A new question is answered every 9 seconds

I am trying to move to the next step in my projec. When I

This answer was rated:

I am trying to move to the next step in my projec. When I run my macro via batch-vbs, the macro seems to become disabled. I have one test file that will select, a range, then use the sendkeys to sort. My final macro will use the PDFMaker addin with Sendkeys. Read that Add-Ins have to be opened when using an Object to open Excel through VBS. Found some sample code, but cannot figure out how to get it working. Why doesn't test file open, and want to open appropriate add-ins w VBS
Thank you for requesting me

Can I look at your excel file please?

- Click the following link: http://www.wikisend.com
- Upload the file to that website
- Once it is uploaded, the resulting page will display a "File ID" number.
- Please, give me that "File ID Number"

Thank you
Customer: replied 3 years ago.

http://wikisend.com/download/398396/test (1).xlsm


 


VBS
Set xl = CreateObject("Excel.application")


xl.Application.Workbooks.Open "C:\sentimenttemplates\test.xlsm"
xl.Application.Visible = True
xl.Application.run "'c:\sentimenttemplates\test.xlsm'!macro1"
'xl.Quit



Set xl = Nothing


 


bat


@echo off


cscript "c:\SentimentTemplates\VBtest.vbs"


 


I have found my macros run ok via auto_exec, but not with the VBS-batch that we developed. This macro1 is my first test which doesn't run. Then, I have another test file, that will pass send keys to use the PDFMAKER addin which is the real macro I want to run. I read that addins are not opened with the object method that we use in the vbs and have some test code for this, but am not sure how to implement. I would like help w/ both these issues, but want to start small with macro1.

You cannot run the Macro from Autoexec, you run it from the VBS script.

So, rename the Sub in the Excel from Autoexec to

public sub sendK()

Then use this code in the VBS (I am assuming you still have it in c:\testt



Set xl = CreateObject("Excel.application")

xl.Application.Workbooks.Open "c:\testt\test.xlsm"
xl.Application.Visible = True
xl.Application.run "'c:\testt\test.xlsm'!sendK"

Set xl = Nothing

It then runs.

Let me know the results please

Thank you
Customer: replied 3 years ago.

macro1 is not located in the autoexec. It is a stand alone. It just doesn't run properly. Can you run this vbs/bat with text.xlsm to see if it runs for you. It sees to disable.

yes, it will also run correctly (message box Hi)

Use this code in the VBS file.



Set xl = CreateObject("Excel.application")

xl.Application.Workbooks.Open "c:\testt\test.xlsm"
xl.Application.Visible = True
xl.Application.run "'c:\testt\test.xlsm'!Macro1"

Set xl = Nothing

Customer: replied 3 years ago.

Wait, the macro we are looking at is Macrotest, not the macro1.


Look at that one

Also works,

Any will work Marilyn, as long as you update the VBS file.

For example, to run MacroTest you put in MacroTest on the second last line

Like below


Set xl = CreateObject("Excel.application")

xl.Application.Workbooks.Open "c:\testt\test.xlsm"
xl.Application.Visible = True
xl.Application.run "'c:\testt\test.xlsm'!MacroTest"

Set xl = Nothing


You see xl.Application.run "'c:\testt\test.xlsm'!MacroTest"

Thats the bit that runs the Macro on open.

Customer: replied 3 years ago.

Did you actually run it to verify?


 


The other piece to my question is that I my macro will be using an addin (PDFMaker) . and it said something about addins need to be opened via the vbs code as a step after the Create Object so I needed you to help me with this additional code.


 


This looks like my add-in C:\Program Files (x86)\Adobe\Acrobat 11.0\PDFMaker\Office\PDFMOfficeAddin.dll

Yes I do,

I have run it succesfully every time you have asked.

Why, is it not working for you?


The code you need to enable the Add in for the PDFMaker is

XL.AddIns("Add In Name").Installed = True

You need to replace Add in Name with the name if the Add in.

So your VBS would be

Set xl = CreateObject("Excel.application")

xl.Application.Workbooks.Open "c:\testt\test.xlsm"
xl.Application.Visible = True
XL.AddIns("Add In Name").Installed = True
xl.Application.run "'c:\testt\test.xlsm'!MacroTest"

Set xl = Nothing


Then the Macro can use the Add in.
Customer: replied 3 years ago.

Interesting. What version of Excel and Windows are you running this on? Sounds like the first part should work. I wonder why it doesn't.. I've been running this over and over with no luck.


 


In the Addin name, do you think I would put "C:\Program Files (x86)\Adobe\Acrobat 11.0\PDFMaker\Office\PDFMOfficeAddin.dll" in that? Also, have you heard of an addin ending in dll. This is what I saw when I looked in Excel on the PDFMaker addin.

Windows 7 and Excel 2010 but this works on all versions of excel.

Are you using my code for the VBS?

The addin name will be the actual name listed in the adding in Excel.

From what you are saying this looks to be PDFMaker, but check in Addins in Excel to get its name. It is not the DLL name, that is the actual add in file.

Richard and 6 other Microsoft Office Specialists are ready to help you
Customer: replied 3 years ago.

Hum, that is the versions of both that I have. Is there anyway that you can connect to my machine so you can see.


 


I am using the exact code we worked on.


 


I did a google on PDFMaker.xla which does exists. Maybe that could be the one?


Go to Click Me

Click START MEETING

It will download a program to your computer

Run the program by double clicking it, and it will give you a set of 9 numbers

Give me the numbers at the top of the screen (eg: 456-789-123) in your message to me here please

Thank you
Customer: replied 3 years ago.

507-586-001

Logging on
Fixed!
Richard and 6 other Microsoft Office Specialists are ready to help you