nkpan
05-27-2018, 10:36 PM
Hello,
I am working on a word macro where I have a user from and i want to open an excel file though a command button.
I have declared Xl and WB1 as global variables in a Module.
The code in the command button goes as below
Private Sub cmdDelete_Click()
Dim k As Integer
Set Xl = New Excel.Application
Set WB1 = Xl.Workbooks.Open(AutoAbbreviations.txtPath.Value, ReadOnly:=False)
Xl.Visible = True
WB1.Activate
WB1.Worksheets("Abb-List").Activate
k = WB1.Worksheets("Abb-List").Range("A" & Rows.Count).End(xlUp).Row
,
,
,
End Sub
Even though my code states ReadOnly:= False still the workbook open in read only for the below code line
Set WB1 = Xl.Workbooks.Open(AutoAbbreviations.txtPath.Value, ReadOnly:=False)
Also
I am getting an error on this line:
k = WB1.Worksheets("Abb-List").Range("A" & Rows.Count).End(xlUp).Row
The error msg is
Run Time error 1004
Method 'Rows' of ojbect"_Global' failed
Would really appreciate if some expert can help on this.
Thank you
I am working on a word macro where I have a user from and i want to open an excel file though a command button.
I have declared Xl and WB1 as global variables in a Module.
The code in the command button goes as below
Private Sub cmdDelete_Click()
Dim k As Integer
Set Xl = New Excel.Application
Set WB1 = Xl.Workbooks.Open(AutoAbbreviations.txtPath.Value, ReadOnly:=False)
Xl.Visible = True
WB1.Activate
WB1.Worksheets("Abb-List").Activate
k = WB1.Worksheets("Abb-List").Range("A" & Rows.Count).End(xlUp).Row
,
,
,
End Sub
Even though my code states ReadOnly:= False still the workbook open in read only for the below code line
Set WB1 = Xl.Workbooks.Open(AutoAbbreviations.txtPath.Value, ReadOnly:=False)
Also
I am getting an error on this line:
k = WB1.Worksheets("Abb-List").Range("A" & Rows.Count).End(xlUp).Row
The error msg is
Run Time error 1004
Method 'Rows' of ojbect"_Global' failed
Would really appreciate if some expert can help on this.
Thank you