Compile Error

josros60

Well-known Member
Joined
Jun 27, 2010
Messages
786
Office Version
  1. 365
HI,

I have the code below and it was working fine (Open excel file from outlook) but suddenly getting this error:

Compile Error:
Method or data member not found (on the line below)

Code:
Set xWb = xExcelApp.Workbooks.Open(xExcelFile)


Complete code:

Code:
Public Sub OpenVendorChartofAcounts() Dim xExcelFile As String
    Dim xExcelApp As Excel.Application
    Dim xWb As Excel.Workbook
    Dim xWs As Excel.Worksheet
    Dim xExcelRange As Excel.Range
    xExcelFile = "\\mtlnas01\share\Accountant Files\AP Team\Jose\NCL_XLSM\CHART OF ACCOUNTS.xlsm"
    Set xExcelApp = CreateObject("Excel.Application")
    Set xWb = xExcelApp.Workbooks.Open(xExcelFile)
    Set xWs = xWb.Sheets(1)
    xWs.Activate
    Set xExcelRange = xWs.Range("A1")
    xExcelRange.Activate
    xExcelApp.Visible = True
    xWb.Windows(1).WindowState = xlMaximized
    
End Sub
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hi,
Not sure about the reason of the issue, check the absence of the 'MISSING:...' items in VBE-Tools-References
You may also try this - Set xExcelApp = New Excel.Application instead of the code line with CreateObject
 
Upvote 0
i tried your suggestion still same error.

it's weird because the other files open from outlook opens ok same code just this one no sure nothing has been changed.

thank you
 
Upvote 0
Is there any code in the Workbook_Open event of that workbook?
 
Upvote 0
... the other files open from outlook opens ok same code just this one
If code is working with other workbooks then my suggestion in post 2 can't help.
However, one of the problem can be in a fact that XLSMs is blocked.
How to unblock XLSM read in this page of JKP site.
 
Last edited:
Upvote 0
no there's no Workbook_Open event in this file

I also checked the site still same prolbem

thank you for all suggestions.

 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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