Access-to-Excel Automation - Saving Excel w/ Custn Filename

G

Guest

I posted this before in the Access Newsgroups, but we never found the
solution...It works about half the time.

Here's a snippet from the Access code...

....BegPar and EndPar are unbound textboxes on an Access Form...
A = Month(BegPar): K = Day(BegPar): C = Year(BegPar)
L = Month(EndPar): E = Day(EndPar): F = Year(EndPar)
M = "AIP" & Right("0" & A, 2) & Right("0" & K, 2) _
& Right(C, 2) & "_" & Right("0" & L, 2) & Right("0" & E, 2) _
& Right(F, 2)
If IsNull(Combo505) Then
S = "_Both"
IPFile = "C:\BobDev\" & M & S & ".xls"
Else
S = Combo505 & "_"
IPFile = "C:\BobDev\" & S & M & ".xls"
End If
bIPFile = True: ChDir "C:\BobDev"
If Dir(IPFile) <> "" Then Kill IPFile
AAA3:
ActiveWorkbook.SaveAs filename:=IPFile, FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

...When it fails...it's the code directly under "AAA3:" above.
The "ActiveWorkbook" is a File called thru Automation...after I
populate the Excel data from Access Automation, I save the File
w/ the "IPFile" string above.

TIA - Bob
 
G

Guest

I needed the fully qualified reference to the workbook.

IE..like
ExcelApp.ActiveWorkbook.....

That corrected it - Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top