VBA for decimals and saving

cjtaylor0103

New Member
Joined
Apr 10, 2023
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hello,

No coding experience other than what I've done here to stitch together a few people's code. I'm almost where I need to be, but have 2 problems.

First, this line of code is grabbing data from an excel spreadsheet and moving it in to a word template. When the data being moved is a currency and the currency ends in a .00 or .#0, it cut's off the zero(s) in the output file. $95.00 turns to $95 and $95.50 turns to $95.5. How might I adjust this code to bring in two decimals even if one or both are zeros?

VBA Code:
    .Application.Selection.Find.Text = "<<total!>>"
    .Application.Selection.Find.Execute
    .Application.Selection = Sheet1.Cells(r, 13).Value
    .Application.Selection.EndOf

Second, I'm hoping to save the created document as a PDFs instead of .docx. The target file for moving excel data is a Word Template (.dotx). Can I adjust the below code to output a PDF document when I run the macro?

VBA Code:
    custN = Sheet1.Cells(r, 3).Value
    type1 = Sheet1.Cells(r, 5).Value
    path = ActiveWorkbook.path & "\OUTPUT\"
    .SaveAs2 Filename:=path & custN & "_" & type1, _
    FileFormat:=wdFormatXMLDocument, AddtoRecentFiles:=False


Many thanks for the assist!
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,215,102
Messages
6,123,097
Members
449,096
Latest member
provoking

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