Export File As A Fixed Format

thehelgeson13

New Member
Joined
Jan 6, 2014
Messages
4
Hello,

I have been assigned the task of developing a excel document that whole office will use. The user will click a button and the macro will export the file as a PDF to a shared folder. I wrote this code and tested this code using excel 2010. People that have excel 2007 where getting an error message saying "Run Time Error 1004 Document not saved. This document may be open, or an error may have been encountered when saving." I looked into the problem a little bit and found that excel 2007 needed an add-in update, so I installed it on their computers. I also checked to see if they have adobe on their computers and they do. They are still having the problem and I am unsure of what to do. Any help would be greatly appreciated!

Here is my code

'Save As New File
Worksheets("Input Data").Visible=True
folder=Sheets("Input Data").Range("location").Value
MyTime=Time
Sheets("Input Data").Select
Range("G2").Value=MyTime
strFileName=folder & "Material Request- "& Sheets ("Input data").Range("name").Value& "_"&Sheets("Input data").Range("date").Value&""&Sheets("Input data").Range("time").Value& ".pdf"
Sheets("Material Request").select
ActiveSheet.ExportasFixedFormat Type:=xlTypePDF, FileName'OpenAfterPublish:=True
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Apologizes this is the correct code

' Save as new file approved
Worksheets("Input data").Visible = True
folder = Sheets("Input data").Range("location_approved").Value
MyTime = Time
Sheets("Input data").Select
Range("G2").Value = MyTime
strFileName = folder & "Material Request - " & Sheets("Input data").Range("name").Value & "_" & Sheets("Input data").Range("date").Value & " " & Sheets("Input data").Range("time").Value '& ".pdf"
Sheets("Material Request").Select
Worksheets("Input data").Visible = False
ActiveWorkbook.SaveAs Filename:=strFileName
 
Upvote 0
Why not just record the macro in Excel 2007? Doesn't look like you'd have to adjust much.

Also, you have...
Code:
ActiveSheet.ExportasFixedFormat Type:=xlTypePDF, FileName'OpenAfterPublish:=True

Doesn't look like the variable "FileName" is in your code... do you mean strFileName?
Might need to be:
Code:
, FileName:= strFileName
 
Upvote 0
I tried to record it and no luck. I think it has something to do with the Filename but im not sure


' Define all variables
Dim strFileName As String
Dim folder As String
Dim member As Integer
Dim member_count As Integer
Dim member_name As String
Dim show As Variant
Dim MyTime As String

Application.ScreenUpdating = False
Application.DisplayAlerts = False

'Creates new worksheet
Worksheets("Approval").Visible = True

'Save as new file
Worksheets("Input data").Visible = True
folder = Sheets("Input data").Range("location").Value
MyTime = Time
Sheets("Input data").Select
Range("G2").Value = MyTime
strFileName = folder & "Material Request - " & Sheets("Input data").Range("name").Value & "_" & Sheets("Input data").Range("date").Value & " " & Sheets("Input data").Range("time").Value & ".pdf"
Sheets("Material Request").Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=strFileName 'OpenAfterPublish:=True
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,399
Members
448,957
Latest member
Hat4Life

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