Message 1 of 3

Not applicable
08-24-2017
02:55 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The first time I run this VBA code, the first message box displays the correct number of sheets, and then throws an error "Object Required" on the "Set oSheetCount = ". Subsequent attempts result in "Object Required" immediately.
Translating the code to iLogic works perfectly, but i am trying to learn VBA, and successively VB.NET. Can someone help me understand why this is happening?
VBA Code
Public Sub SheetCount() Dim oDoc As DrawingDocument Set oDoc = ThisApplication.ActiveDocument MsgBox (oDoc.Sheets.Count) Dim oSheetCount As Integer Set oSheetCount = oDoc.Sheets.Count MsgBox (oSheetCount) End Sub
iLogic
Dim oDoc as DrawingDocument = ThisApplication.ActiveDocument MessageBox.Show(oDoc.Sheets.Count) Dim oSheetCount As Integer = oDoc.Sheets.Count MessageBox.Show(oSheetCount)
Solved! Go to Solution.