IcePirate
03-04-2009, 11:45 AM
Hello, this topic, related to my thread here
http://www.vbaexpress.com/forum/showthread.php?p=177567
I have ensured this topic is not cross posted, and if I do place this question on other forums Ill post links here.
I have a simple Macro (see below) Im trying to create two instances of this Macro one to fill in the first_mark book mark, and the second to fill in the second_mark book mark, (but all in one Macro)...I tried using IF, and With to separate the statements, but Im getting nothing but errors, was hoping someone could help out.
Sub AutoOpen()
Dim myWB As Excel.Workbook
Dim TempStr As String
Set myWB = GetObject("C:\PROJECT\excel.xls")
Selection.GoTo What:=wdGoToBookmark, Name:="first_mark"
Selection.TypeText (CStr(myWB.Sheets("PayHist").Range("A" & 1)))
Set myWB = Nothing
With myWB
Selection.GoTo What:=wdGoToBookmark, Name:="SECOND_mark"
Selection.TypeText (CStr(myWB.Sheets("PayHist").Range("A" & 1)))
End With
End Sub
http://www.vbaexpress.com/forum/showthread.php?p=177567
I have ensured this topic is not cross posted, and if I do place this question on other forums Ill post links here.
I have a simple Macro (see below) Im trying to create two instances of this Macro one to fill in the first_mark book mark, and the second to fill in the second_mark book mark, (but all in one Macro)...I tried using IF, and With to separate the statements, but Im getting nothing but errors, was hoping someone could help out.
Sub AutoOpen()
Dim myWB As Excel.Workbook
Dim TempStr As String
Set myWB = GetObject("C:\PROJECT\excel.xls")
Selection.GoTo What:=wdGoToBookmark, Name:="first_mark"
Selection.TypeText (CStr(myWB.Sheets("PayHist").Range("A" & 1)))
Set myWB = Nothing
With myWB
Selection.GoTo What:=wdGoToBookmark, Name:="SECOND_mark"
Selection.TypeText (CStr(myWB.Sheets("PayHist").Range("A" & 1)))
End With
End Sub