Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hello, I am developping a VB appli

Status
Not open for further replies.

Foxama

Programmer
Feb 1, 2021
3
IT
Hello,
I am developping a VB application dealing with MSGraph graphs. I want to create a pdf document of the graph handled from inside the app.

To print the graph in .pdf format I do the following:
first: I set the pdf printer as the default printer to use;
second: I use PrintForm to transfer the graph to the printer.

Everything works fine, except the default name of the file.
When the Adobe common dialog opens to save the file, it always prompts "Microsoft Visual Basic" as the default name to be saved.
I would like to assign a custom file name from inside the application, but till now I tried with no success.
I do not know how to access to ADOB PDF default settings in order to change the file name that is prompted.

I need some help, so I am asking: is anyone so generous to give me an advice to solve my problem ?
 
Could you show your code of:
"When the Adobe common dialog opens to save the file"
so we know what you are working with?

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Hi Andy,
I give you more info.

MTGraph is a form containing a MS Chart, see the link below
MS_chart_hwc7i0.png


the source code is:

Dim Graph1 As MtGraf
set Graph1 = new MtGraph

.... follow instructions to properly set the Chart parameters

'here is the very simple code for printing
Printer.PaperSize = vbPRPSA4
Printer.Orientation = vbPRORLandscape
Graph1.PrintForm
Printer.EndDoc

Print_screen_tqkf1y.png


if the ADOBE PDF printer is set as the default printer, it works fine, showing the common dialog for the selection of the name and the folder where the file has to be saved. Once you click on the SAVE button, the file pdf containing the graph is correctely saved.

I would like to preset the pdf file name before the prompt of the common dialog, avoiding to have always to modify the "Microsoft Visual Basic" default setting that ADOBE PDF printer does.
 
To get this last image, I guess you use a CommonDialog (CommonDialog1?) on your form with some code like:

Code:
Private Sub cmPrintPDF_Click()

With CommonDialog1[blue]
    .FileName = "MyFile.PDF"[/blue]
    .ShowSave
End With

End Sub

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
>To get this last image, I guess you use a CommonDialog

Nah - if you select the Adobe PDF printer as the OP seems to suggest they are doing, then it is that printer driver that presents the dialog. You don't get to set it ...

The only way I am aware of (and god knows why Adobe make this so difficult) is to hack the registry. Try googling Adobe PrinterJobControl
 
strongm is right; there is no CommonDialog control on my form.
I will keep trying either with PrinteJobControl either with VB libraries for generation direct of pdf files.
I will post my progresses, if any ....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top