I'm writing a macro that takes a text file containing code and copies it behind sheet1 of an existing workbook. It works fine on my computer but every time I run it on someone else's computer, Excel gives a fatal error on the following line of code it is importing.... Not sure why.
Dim rsData as ADODB.Recordset
Below is my vba code and I also attached the text file.
Add Code Code:
Sub UpdateThisWorkbook()
On Error GoTo DownHere
Dim VBProj As VBIDE.VBProject
Dim VBComp As VBIDE.VBComponent
Dim CodeMod As VBIDE.CodeModule
Dim LineNum As Long
Dim oFS
Dim FsFile
Set FsFile = CreateObject("Scripting.FileSystemObject")
Set oFS = FsFile.OpenTextFile(ThisWorkbook.Path + "\copy sheet1 code.txt")
they have no reference to ADO, when the project loads, so get error on that line change to Dim rsData as object
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
i saw that, but they are not there when the project starts
also need to make sure the specific version is available on the target machine
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
i got too many type mismatch errors, running the code to insert references
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
It works fine on my computer but every time I run it on someone else's computer, Excel gives a fatal error on the following line of code it is importing.... Not sure why.
Sorry to add to your troubles but Application.Filesearch is not supported in Excel 2007...
I will test your file when I get back home where I have access to Excel 2003...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread "Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero