Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default On Open using Public Var from VBS?

I create multiple reports through out the day and the source for some of
these reports comes to me through SharePoint. To that end, I have a VBS
script I call from Outlook when an email notification comes in telling me
that my source is available. This script streams the source from the
SharePoint URL to a predetermined location.

What I am theorizing about is a means of setting up a "Public Variable" in
the VBS Script that could be passed to the On Open event in a given Excel
Workbook which in turn, would run a specific macro to import the newly
acquired data.

I assume I would have to put a logic statement in the On Open event that
would test to see if this public variable has been set. If not, it would
simply end. But if the public variable is set, it would run the applicable
macro.

I am always trying to get to 100% automation where I can - is this even
possible?

I thank all the brilliant and capable people out there in advance!

Regards,
Ray

--
"Trying to make reports so easy... even a monkey could run ''em!"
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default On Open using Public Var from VBS?

Why does it seem that I can't ever find an answer until I post here?!

I solved this with the following vbscript:


Dim xlApp
Dim xlWkb
Const ForceExit = True

Dim WBPath
WBPath = "\\WorkbookLocation\Here\"
Dim WBName
WBName = "WB_Name.xls"

Set xlApp = CreateObject("excel.application")
Set xlWkb = xlApp.Workbooks.Open(WBPath & WBName)

'Run the On Open macro (xlautoopen = 1)
xlWkb.RunAutoMacros 1

xlApp.Run WBName & "!Macro2"

'Choose to dispay Excel or Close Excel
'based on ForceExit variable
If ForceExit Then
xlWkb.Close 0
xlApp.Quit
Set xlWkb = Nothing
Set xlApp = Nothing
Else
xlApp.Visible = True
End If



--
"Trying to make reports so easy... even a monkey could run ''em!"


"RayportingMonkey" wrote:

I create multiple reports through out the day and the source for some of
these reports comes to me through SharePoint. To that end, I have a VBS
script I call from Outlook when an email notification comes in telling me
that my source is available. This script streams the source from the
SharePoint URL to a predetermined location.

What I am theorizing about is a means of setting up a "Public Variable" in
the VBS Script that could be passed to the On Open event in a given Excel
Workbook which in turn, would run a specific macro to import the newly
acquired data.

I assume I would have to put a logic statement in the On Open event that
would test to see if this public variable has been set. If not, it would
simply end. But if the public variable is set, it would run the applicable
macro.

I am always trying to get to 100% automation where I can - is this even
possible?

I thank all the brilliant and capable people out there in advance!

Regards,
Ray

--
"Trying to make reports so easy... even a monkey could run ''em!"

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Set Public Variable on Open jlclyde Excel Discussion (Misc queries) 4 September 11th 09 07:03 PM
Public? Chip Pearson Excel Programming 0 January 17th 07 11:28 PM
Use of PUBLIC BillCPA Excel Programming 6 June 7th 06 01:41 PM
public sub Bob Excel Programming 3 December 10th 04 08:49 PM
Public Sub Help No Name Excel Programming 2 May 18th 04 11:09 PM


All times are GMT +1. The time now is 06:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"