Controlling a msp macro function argument using Excel VBa

HosseinReihai

New Member
Joined
Dec 30, 2015
Messages
5
Hello All


I am Mohammad Hossein Reihani an Industrial Engineering student.


I want to find a way by which I can control a macro function which I have written in the MSP from Excel.


For example, I have a function which opens a specific mpp format file. the argument of the function is the address of that file in my computer and is what I want to be changed from Excel. I have tested this code:


[FONT=georgia, serif]Public Function GoProject(func As String)
[FONT=georgia, serif][/FONT]
[FONT=georgia, serif] 'Opens Microsoft Project[/FONT]
[FONT=georgia, serif] Shell ("msproject.exe")[/FONT]
[FONT=georgia, serif][/FONT]
[FONT=georgia, serif] 'Initiates a DDE channel to Microsoft Project[/FONT]
[FONT=georgia, serif] Chan = DDEInitiate("msproject", "system")[/FONT]
[FONT=georgia, serif][/FONT]
[FONT=georgia, serif] 'Activates Microsoft Project[/FONT]
[FONT=georgia, serif] Application.<wbr>ActivateMicrosoftApp xlMicrosoftProject[/FONT]
[FONT=georgia, serif][/FONT]
[FONT=georgia, serif] 'Runs the Project global macro "AdjustDates"[/FONT]
[FONT=georgia, serif] Application.DDEExecute Chan, "AdjustDates"[/FONT]
[FONT=georgia, serif][/FONT]
[FONT=georgia, serif] 'Terminates the DDE channel[/FONT]
[FONT=georgia, serif] Application.DDETerminate Chan[/FONT]
[FONT=georgia, serif][/FONT]
[FONT=georgia, serif] End Function[/FONT]
[FONT=georgia, serif][/FONT]
[FONT=georgia, serif]and changed the red color macro name with my desired function , which has been written in msp:[/FONT]
[FONT=georgia, serif]
[/FONT]
[FONT=georgia, serif]Function OpenProjFile(address As String)

FileOpenEx Name:=address, ReadOnly:=False, FormatID:="MSProject.MPP"


End Function


but it does not work. must declare an object or a string ( I wrote: "OpenProjFile(address)" where address is "C:\temp\myproject.mpp")


I would be glad if you could give me some advice.


Al the best and happy new year,
Hossein
[/FONT]
[/FONT]
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,215,039
Messages
6,122,802
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top