Author Topic: Macro  (Read 4441 times)

0 Members and 1 Guest are viewing this topic.

krampaul82

  • Guest
Macro
« on: January 18, 2013, 12:38:50 PM »
Good Afternoon
Is it possible to open an Excell Document from a MSword vba Application?
code so far

Sub Get_Req_for_WEBS()

'
' Get_Req_for_WEBS
' This Will Open A WEBS Information sheet Specific to Mark
'

 ChangeFileOpenDirectory "C:\gtc_proj\VBA_word\Excel_2007_doc\Mark\"
    Documents.Open FileName:= _
        "C:\gtc_proj\VBA_word\Excel_2007_doc\Mark\EXCEL.*" _ This is where i would like to launch an Excel File
        , ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _
        PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
        WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _
        wdOpenFormatAuto, XMLTransform:=""
    'Windows("Document1").Activate
    End
End Sub

any help appreciated

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Macro
« Reply #1 on: January 18, 2013, 12:49:10 PM »
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

krampaul82

  • Guest
Re: Macro
« Reply #2 on: January 18, 2013, 01:04:49 PM »
Thanks for the Nudge Matt 8-)

krampaul82

  • Guest
Re: Macro
« Reply #3 on: January 18, 2013, 03:03:51 PM »
Good afternoon

Found this code:

Sub OpenExcel_Letter_of_trans()
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
strDir = "V:\gtc_proj\VBA_word\Excell_2007_doc\"
strFile = "_Master Letter of Transmittal.xls"
ShellExecute 0, "OPEN", strDir & strFile, "", strDir, 1
End Sub

does not work  does not like the Declare function any ideas?
any help appreciated
Mark

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Macro
« Reply #4 on: January 18, 2013, 03:22:58 PM »
Try this instead...

Code: [Select]
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Sub OpenExcel_Letter_of_trans()
   strDir = "V:\gtc_proj\VBA_word\Excell_2007_doc\"
   strFile = "_Master Letter of Transmittal.xls"
   ShellExecute 0, "OPEN", strDir & strFile, "", strDir, 1
End Sub
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

krampaul82

  • Guest
Re: Macro
« Reply #5 on: January 18, 2013, 03:40:51 PM »
It says the object invoked has disconnected from its clients.

krampaul82

  • Guest
Re: Macro
« Reply #6 on: January 18, 2013, 04:02:47 PM »
Matt
I got it to work! it was user error! Imagine that!
Thank you for your help
Mark 8-)

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Macro
« Reply #7 on: January 20, 2013, 06:23:30 AM »
You're welcome!   :kewl:
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io