Creating a ms publisher document

bretdunlap

Registered User.
Local time
Today, 03:01
Joined
Nov 15, 2011
Messages
54
I can successfully create a ms Pub doc and import what I need the challenge is I can't seam to figure out how to change the orientation to landscape.

Private Sub Command393_Click()
Dim wObj As Object
Dim SText As Variant
Dim PubDoc As Object
Dim pbshape As Object


On Error Resume Next
DoCmd.Hourglass True
If Len(StudentID) = 0 Then Exit Sub



Set wObj = GetObject(, "Publisher.Application")
If Err <> 0 Then
Set wObj = CreateObject("Publisher.Application")
End If
wObj.Visible = True



SText = ""

SText = "TO: " & Chr(13)
SText = SText & GuardianFirst1 & " " & GuardianLast1 & Chr(13)
SText = SText & Street & Chr(13)
SText = SText & City & " " & State & ", " & Zip



Set PubDoc = wObj.Documents.add
PubDoc.Orientation = pbOrientationLandscape


Set pbshape = PubDoc.Pages(1).Shapes.AddTextbox(1, -72, 210, 171, 75)
pbshape.TextFrame.TextRange.Text = SText
pbshape.TextFrame.TextRange.Font.Size = 12
pbshape.TextFrame.TextRange.Characters(Start:=1, Length:=3).Font.Bold = True
pbshape.TextFrame.TextRange.Characters(Start:=1, Length:=3).Font.Size = 18
pbshape.TextFrame.TextRange.Font.Name = "Arial"

SText = "Mr. A's Martial Arts" & Chr(10) & "31 South Eagle Rd" & Chr(10) & "Havertown, PA 19083" & Chr(10) & "(Lower Level Next to Fremeworks And Dominos Pizza)"

Set pbshape = PubDoc.Pages(1).Shapes.AddTextbox(1, -72, 100.5, 225, 65)
pbshape.TextFrame.TextRange.Text = SText
pbshape.TextFrame.TextRange.Font.Size = 12
pbshape.TextFrame.TextRange.Characters(Start:=1, Length:=6).Font.Bold = True
pbshape.TextFrame.TextRange.Characters(Start:=1, Length:=6).Font.Size = 15
pbshape.TextFrame.TextRange.Characters(Start:=59, Length:=54).Font.Size = 8
pbshape.TextFrame.TextRange.Font.Name = "Arial Rounded MT Bold"

SText = "Dear " & FirstName & "," & Chr(10) & Chr(10) & Chr(9) & txtgoodjobnote & Chr(10) & Chr(10) & "Your next Appointment with Mr. D is on " & Format(IntroDate, "Long Date") & " at " & Format(IntroTime, "Medium Time") & Chr(10) & Chr(10) & "Mr. D"

Set pbshape = PubDoc.Pages(1).Shapes.AddTextbox(1, 120, 186, 177, 195.75)
pbshape.TextFrame.TextRange.Text = SText
pbshape.TextFrame.TextRange.Font.Size = 12
pbshape.TextFrame.TextRange.Font.Bold = True
pbshape.TextFrame.TextRange.Font.Italic = True
pbshape.TextFrame.TextRange.Font.Name = "Arial"

Set pbshape = PubDoc.Pages(1).Shapes.AddLine(BeginX:=110, BeginY:=200, EndX:=110, EndY:=300)
pbshape.Line.Weight = 2.3





DoCmd.Hourglass False



Dim str_folder As String
Dim PubFolder As String
PubFolder = DLookup("[Pic Path]", "Pic Path Table2", "ID = 34")

str_folder = PubFolder


Call Shell("explorer.exe " & str_folder, vbNormalFocus)
End Sub
 
PubDoc.PageSetup.Orientation = pbOrientationLandscape
 
Thanks for the suggestion I have tried placing in almost every spot I can think of and sill nothing. I even tried placing set in front of your code. Any more suggestions?
 

Users who are viewing this thread

Back
Top Bottom