FlavorFlav
New Member
- Joined
- Mar 29, 2023
- Messages
- 4
- Office Version
- 365
- Platform
- Windows
Hi all!
I am struggling with the VBA error 462. I checked multiple other pages with a similar issue, but no of them did help me really. It is just changing the place in the code where the error occurs.
Shortly what I did:
- For Requirements Engineering & Changge request managment I need an Excel which helps me to write down meeting notes with our clients. The idea is to start everything from Excel (Mails, Tasks, Word, etc.), which works perfectly fine except the Error 462.
The line of code is the following, where the "WordFullName" is a combination of the File Path to Sharepoint & the file name (e.g. https://asdadasda.sharepoint.com/:w:/s/PR..../ProjectAAA.docx". This is checked with an "URL existance function" (which works fine after a lot of research). But in the following part of code I get sometimes an error message 462.
Can anybody help me there? I tried several other option to solve this error, but it only moves the line of code which the error is showing. After "reseting" the VBA Code, the Sub procedure is running without problems again for 1 round.
Thanks in Advance!
---------------------------------------------------
I am struggling with the VBA error 462. I checked multiple other pages with a similar issue, but no of them did help me really. It is just changing the place in the code where the error occurs.
Shortly what I did:
- For Requirements Engineering & Changge request managment I need an Excel which helps me to write down meeting notes with our clients. The idea is to start everything from Excel (Mails, Tasks, Word, etc.), which works perfectly fine except the Error 462.
The line of code is the following, where the "WordFullName" is a combination of the File Path to Sharepoint & the file name (e.g. https://asdadasda.sharepoint.com/:w:/s/PR..../ProjectAAA.docx". This is checked with an "URL existance function" (which works fine after a lot of research). But in the following part of code I get sometimes an error message 462.
Can anybody help me there? I tried several other option to solve this error, but it only moves the line of code which the error is showing. After "reseting" the VBA Code, the Sub procedure is running without problems again for 1 round.
Thanks in Advance!
---------------------------------------------------
Rich (BB code):
Sub TableWord(WordFullName As String)
Dim myRange, myTable As Object
Dim OApp As Word.Application
Set OApp = New Word.Application
OApp.Documents.Open (WordFullName)
OApp.Visible = True
Set myRange = OApp.ActiveDocument.Range(Start:=0, End:=0)
If OApp.ActiveDocument.Tables.Count = 0 Then ' Check if table already exists
OApp.ActiveDocument.Tables.Add Range:=myRange, NumRows:=2, NumColumns:=2
Set myTable = OApp.ActiveDocument.Tables(1)
myTable.AutoFormat , 1, 1, 1, 1, 0, 0, 0, 0, 1
With myTable.Borders ' For new table
.InsideLineStyle = wdLineStyleSingle
.OutsideLineStyle = wdLineStyleDouble
End With
With myTable.Cell(1, 1).Range
.Delete
.InsertAfter Text:="Date"
End With
With myTable.Cell(1, 2).Range
.Delete
.InsertAfter Text:="Topic"
End With
With myTable.Cell(2, 1).Range
.Delete
.InsertAfter Text:=ActiveSheet.Range("A46").Value
End With
With myTable.Cell(2, 2).Range
.Delete
.InsertAfter Text:=Sheets("Names_Code").Range("C36").Value
End With
myTable.Columns(1).Width = InchesToPoints(1.1)
myTable.Columns(2).Width = InchesToPoints(5.2)
Else
Set myTable = OApp.ActiveDocument.Tables(1) ' For existing table
myTable.Rows.Add BeforeRow:=myTable.Rows(2)
With myTable.Cell(2, 1).Range
.Delete
.InsertAfter Text:=ActiveSheet.Range("A46").Value
End With
With myTable.Cell(2, 2).Range
.Delete
.InsertAfter Text:=Sheets("Names_Code").Range("C36").Value
End With
myTable.Columns(1).Width = InchesToPoints(1.1)
myTable.Columns(2).Width = InchesToPoints(5.2)
End If
End Sub
Last edited by a moderator: